//<my-matriculator - a simple tool for registering racers in a USAC cyclocross race>
//Copyright (C) <2011>  <Steven Rivers>

//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.

//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with this program.  If not, see <http://www.gnu.org/licenses/>.

using System.ComponentModel;

namespace Registration.Model.Entities
{
    public class Result : INotifyPropertyChanged
    {
        private int _place;

        public int Place
        {
            get { return _place; }
            set { _place = value; OnPropertyChanged(new PropertyChangedEventArgs("Place")); }
        }

        private int _categoryplace;

        public int CategoryPlace
        {
            get { return _categoryplace; }
            set { _categoryplace = value; OnPropertyChanged(new PropertyChangedEventArgs("CategoryPlace")); }
        }

        private int _bib;
        public int BibNumber
        {
            get { return _bib; }
            set
            {
                _bib = value;
                OnPropertyChanged(new PropertyChangedEventArgs("BibNumber"));

            }
        }
        private int _license;
        public int License
        {
            get { return _license; }
            set
            {
                _license = value;
                OnPropertyChanged(new PropertyChangedEventArgs("License"));

            }
        }
        private string _categoryname;
        public string CategoryName
        {
            get { return _categoryname; }
            set { _categoryname = value; OnPropertyChanged(new PropertyChangedEventArgs("CategoryName")); }
        }

        private int _fieldid;
        public int FieldId
        {
            get { return _fieldid; }
            set
            {
                _fieldid = value;
                OnPropertyChanged(new PropertyChangedEventArgs("Field"));

            }
        }
        private string _fname;
        public string FirstName
        {
            get { return _fname; }
            set
            {
                _fname = value;
                OnPropertyChanged(new PropertyChangedEventArgs("FirstName"));

            }
        }
        private string _lname;
        public string LastName
        {
            get { return _lname; }
            set
            {
                _lname = value;
                OnPropertyChanged(new PropertyChangedEventArgs("LastName"));

            }
        }

        private string _club;
        public string Club
        {
            get { return _club; }
            set { _club = value; OnPropertyChanged(new PropertyChangedEventArgs("Club")); }
        }

        public event PropertyChangedEventHandler PropertyChanged;
       
        public void OnPropertyChanged(PropertyChangedEventArgs e)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, e);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != typeof (Result)) return false;
            return Equals((Result) obj);
        }

        public Result(int place, int catplace, int bib, int license, int fieldid, string catname, string fname, string lname, string club)
        {
            Place = place;
            CategoryPlace = catplace;
            BibNumber = bib;
            License = license;
            FieldId = fieldid;
            CategoryName = catname;
            FirstName = fname;
            LastName = lname;
            Club = club;
        }

        public bool Equals(Result other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;
            return other._place == _place && other._categoryplace == _categoryplace && other._bib == _bib && other._license == _license && Equals(other._categoryname, _categoryname) && other._fieldid == _fieldid && Equals(other._fname, _fname) && Equals(other._lname, _lname) && Equals(other._club, _club);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                int result = _place;
                result = (result*397) ^ _categoryplace;
                result = (result*397) ^ _bib;
                result = (result*397) ^ _license;
                result = (result*397) ^ (_categoryname != null ? _categoryname.GetHashCode() : 0);
                result = (result*397) ^ _fieldid;
                result = (result*397) ^ (_fname != null ? _fname.GetHashCode() : 0);
                result = (result*397) ^ (_lname != null ? _lname.GetHashCode() : 0);
                result = (result*397) ^ (_club != null ? _club.GetHashCode() : 0);
                return result;
            }
        }
    }
}